hex_number = input()
flag = True
i = 0
result = 0
ch = hex_number[0]  # ques
while i < len(hex_number) and flag:
    if '0' <= ch <= '9':
        result = result * 16 + int(ch)
    elif 'A' <= ch <= 'F':
        result = result * 16 + ord(ch) - ord('A') + 10
    elif 'a' <= ch <= 'f':
        result = result * 16 + ord(ch) - ord('a') + 10
    else:
        flag = False
    i += 1
    if i == len(hex_number):
        break
    ch = hex_number[i]  # ques

if flag:
    print(result)
else:
    print('输入错误')
